struct codeline;
struct token;
struct textseg;
struct dataseg;
struct runtime;
struct jitngin;
struct syntaxlist;
struct sxbh;
struct varh;
struct ins;

#define SUCCESS 0
#define ERROR -1
#define TRUE 1
#define FALSE 0

/* preprocesser */
// file->codeline
struct codeline * preprocess (const char * file); // done

/* lexer */
// codeline->token
struct token * scan (struct codeline * cl); // done
// 检测语法错误,以及确定变量/指令
struct token * checktoken (struct token * tk); // done

/* parser */
// token -> syntaxlist
struct syntaxlist * parse (struct token * tk); // done
// 检测语义错误
struct syntaxlist * checksyntax (struct syntaxlist * stls); // done
// syntaxlist -> textseg
struct textseg * gettextseg (struct syntaxlist * stls, struct varh * vh); // done
// textseg -> jit
struct jitngin * getjit (struct textseg * ts, struct sxbh * sh); // done
struct dataseg * getdataseg (); // done
// textseg + dataseg + jit -> runtime
struct runtime * getrt (struct textseg * ts, struct dataseg * ds, struct jitngin * jit ,struct varh * vh); // done
// 执行
int ignite (struct runtime * rt); // done
int rtexec (uint64 * regs, struct ins *  inst); // done
int assignvar (void * regs, struct ins * inst); // done
int freeallvar (void * regs); // done

/* 系统调用 */
uint64 ecall (uint64 v, uint64 a0, uint64 a1); // done

/* jit 引擎 */
// 生成tb块
struct transblock * genjitblk (struct jitngin * jit, uint addr); // done
void do_jitexec (void * regs, void * exec); // 使用jit运行 done
int jitexec (uint64 * regs, struct ins *  inst); // done

/* 小可执行块堆分配函数 */
int sxbhinit (struct sxbh * sh ,uint blknm); // 单位2MB/blk done
void * xalloc (struct sxbh * sh, uint sz); // done
void * xrealloc (struct sxbh* sh, void * src, uint newsz); // done
int xfree (struct sxbh* sh, void * addr); // done
/* 变量堆分配函数 */
int varhinit (struct varh * vh, struct dataseg * ds); // done
void * varalloc (struct varh * vh, uint sz); // done
int varfree (struct varh* vh, void * addr); // done